package com.dearbinge.opentapi.content.oldUser;

import com.dearbinge.data.api.oldUser.OldUserService;
import com.dearbinge.data.pojo.oldUser.OldUser;
import com.dearbinge.utils.ResultMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 购物车控制层
 *
 * @author cl
 * @date 2019/1/10
 */
@Api(description = "老用户获取o2接口")
@RestController
@RequestMapping("/oldUser")
@CrossOrigin
public class OldUserController extends WebMvcConfigurerAdapter {

    @Autowired
    private OldUserService oldUserService;

    /**
     * 根据手机号查询老用户o2
     */
    @ApiOperation(value = "根据手机号查询老用户o2",notes = "根据手机号查询老用户o2")
    @ApiImplicitParam(name = "mobile", value = "手机号", paramType = "query")
    @RequestMapping(value = "/getOldUserByMobile",method = RequestMethod.GET)
    public ResultMsg<OldUser> getOldUserByMobile(String mobile) {
        try {
            OldUser oldUser = oldUserService.getOldUserByMobile(mobile);
            return ResultMsg.ok(oldUser);

        }catch (Exception e){
            e.printStackTrace();
        }
        return ResultMsg.error(500,"系统异常");
    }
}
